<template>
  <div class="container">
    <top-bar>
      <div class="top_bar">
        <div class="user-info">
          <div class="user-image"></div>
          <div class="user-info-ms">
            <div class="user-info-title"><span>早上好！Song</span></div>
          </div>
        </div>
        <weather></weather>
        <theme :data=themes></theme>
      </div>

    </top-bar>
    <div class="content">
      <div class="friend-list-box  ">
        <div class="chart-search-area">
          <search-view class="search-view" :data="data"></search-view>
          <div class="plus-add">
            <img src="../../assets/icons/add_plus.svg" alt="">
          </div>
        </div>
        <char-navigation-bar class="nav_bar"></char-navigation-bar>

        <div class="friend-box-li">
          <div class="friend-list list-y">
            <message-card v-for="item in messages" :key="item.title" :message="item"
                          @click="handleClick(item.id,item.title)"
                          :class="curIndex===item.id ?'xactive':null"></message-card>
          </div>
        </div>

      </div>
      <div class="message-window">
        <div class="user-title">
          {{curName?curName :'A 不说晚安 ！' }}
        </div>
        <div class="chat-window">
          <div class="chat-list list-y">
            <chat-message-card v-for="item in chatInfos" :message="item" :key="item.id"></chat-message-card>
          </div>

        </div>
        <div class="edit-window">
          <div class="edit-button-area">
            <div class="expression btn" title="表情"></div>
            <div class="file btn" title="文件"></div>
            <div class="screenshot btn" title="截屏"></div>
            <div class="message-history btn" title="聊天记录"></div>
            <div class="telephone btn" title="语音电话"></div>
            <div class="video btn" title="视频"></div>
          </div>
          <textarea name="text" id="edit-text-area" placeholder="input..."></textarea>
          <div class="send-button">
            <button class="button-64 " role="button"><span class="text">发送</span></button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import TopBar from "@/components/top-bar.vue"
import SearchView from "@/components/search.vue"
import Theme from "@/components/theme.vue"
import CharNavigationBar from "@/components/chat-navigation-bar.vue"
import {reactive, ref} from "vue";
import {themes} from "@/config/data";
import Weather from "@/components/weather.vue"
import MessageCard from "@/components/message-card.vue"
import ActiveDataJson from "@/assets/data/active-data.json"
import ChatMessageCard from "@/components/chat-message-card.vue"
import ChatInfoJson from "@/assets/data/chat-infos.json"

const chatInfos = ChatInfoJson
const messages = ActiveDataJson
const data = reactive<Array<string>>(['Tom', '琳琳'])

let curIndex = ref(50)
const curName = ref("A 不说晚安！")

const handleClick = (id: number, name: string) => {
  curIndex.value = id
  curName.value = name
}
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  display: flex;
  padding: 10px;
  flex-direction: column;

  .content {
    width: 100%;
    height: 100%;
    display: grid;
    margin-top: 10px;
    grid-template-columns: 1fr 3fr;
    grid-column-gap: 10px;

    .friend-list-box {
      background: url("@/assets/icons/transparent-big.png");
      backdrop-filter: blur(3px);
      position: relative;
      width: 100%;
      height: 100%;
      padding: 10px;
      border-radius: 10px;

      .chart-search-area {
        justify-content: space-between;
        display: flex;
        align-items: end;
        position: absolute;
        top: 5px;
        left: 10px;
        right: 10px;
        margin-bottom: 10px;

        .search-view {
          width: 80%;
        }

        .plus-add {
          width: 30px;
          height: 30px;
          background-color: rgba(255, 255, 255, 0.6);
          display: flex;
          cursor: pointer;
          align-items: center;
          justify-content: center;
          border-radius: 5px;

          img {
            width: 24px;
            height: 24px;
          }
        }
      }

      .nav_bar {
        width: 95%;
        height: 55px;
        position: absolute;
        top: 55px;
        left: 5px;
        right: 5px;
      }

      .friend-box-li {
        position: absolute;
        left: 5px;
        right: 5px;
        top: 115px;
        bottom: 15px;
        margin-top: 5px;
        width: 95%;

        .friend-list {
          width: 100%;
          height: 100%;

        }
      }


    }

    .message-window {
      position: relative;
      overflow: hidden;
      background: url("@/assets/icons/transparent-big.png");
      border: gray solid 2px;
      border-radius: 15px;

      .user-title {
        width: 100%;
        height: 50px;
        color: white;
        font-size: 20px;
        padding-left: 20px;
        line-height: 50px;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
      }

      .edit-window {
        position: absolute;
        width: 100%;
        height: 30%;
        bottom: 0;
        left: 0;
        right: 0;
        background: url("@/assets/icons/transparent-big.png");


        .send-button {
          position: absolute;
          right: 10px;
          bottom: 15px;
          width: 100px;
          height: 30px;
        }

        .edit-button-area {
          height: 40px;
          width: 100%;
          position: absolute;
          top: 0;
          left: 0;
          right: 0;

          .btn {
            width: 24px;
            height: 24px;
            cursor: pointer;
            background-position: center;
            top: 5px;
            background-size: 24px 24px;
            background-repeat: no-repeat;
          }

          .expression {
            position: absolute;
            left: 10px;
            background-image: url("@/assets/icons/circle-children.png");
          }

          .file {
            position: absolute;
            left: 50px;
            background-image: url("@/assets/icons/filed.png");
          }

          .message-history {
            position: absolute;
            left: 120px;
            background-image: url("@/assets/icons/message-w.png");
          }

          .screenshot {
            position: absolute;
            left: 85px;
            background-image: url("@/assets/icons/cut.png");
          }

          .telephone {
            position: absolute;
            right: 50px;
            background-image: url("@/assets/icons/phone.png");
          }

          .video {
            position: absolute;
            right: 15px;
            background-image: url("@/assets/icons/video-recorder.png");
          }
        }

        #edit-text-area {
          border: none;
          outline: none;
          resize: none;
          position: absolute;
          background: url("@/assets/icons/transparent-big.png") rgba(255, 255, 255, 0.3);
          backdrop-filter: blur(2px);
          color: white;
          font-size: 16px;
          padding: 10px;
          top: 35px;
          left: 0;
          right: 0;
          width: 100%;
          bottom: 0;
        }
      }

      .chat-window {
        width: 100%;
        left: 0;
        right: 0;
        position: absolute;
        background: url("@/assets/icons/transparent-big.png") rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(2px);
        bottom: 30%;
        top: 50px;

        .chat-list {
          width: 100%;
          height: 100%;
          display: flex;
          flex-direction: column;
        }
      }

    }


  }
}

.top_bar {
  display: flex;
  -webkit-app-region: drag; //设置可拖拽，但是要在子组件不需要拖到的地方取消，不然会失焦
  align-content: center;
  padding: 0 0 0 60px;
  justify-content: space-between;

  .user-info {
    display: flex;
    align-items: center;
    justify-content: space-evenly;

    .user-info-ms {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      color: white;
      margin-left: 15px;
      align-items: start;

      .user-info-title {
        font-size: 20px;
      }

      .user-info-describe {
        font-size: 14px;
      }
    }
  }

  .user-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    background-image: url("@/assets/images/pic_5ijxAKSAYKErWtalMemh2.jpg");
    background-size: 40px 40px;
    background-position: center;
  }
}


/* CSS */
.button-64 {
  align-items: center;
  background-image: linear-gradient(144deg, #AF40FF, #5B42F3 50%, #00DDEB);
  border: 0;
  border-radius: 8px;
  box-shadow: rgba(151, 65, 252, 0.2) 0 15px 30px -5px;
  box-sizing: border-box;
  color: #FFFFFF;
  display: flex;
  font-family: Phantomsans, sans-serif;
  font-size: 16px;
  justify-content: center;
  padding: 3px;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
  cursor: pointer;
}

.button-64:active,
.button-64:hover {
  outline: 0;
}

.button-64 span {
  background-image: linear-gradient(to right, #ec77ab 0%, #7873f5 100%);
  padding: 5px 10px;
  border-radius: 6px;
  width: 100px;
  height: 100%;
  transition: 300ms;
}

.button-64:hover span {
  background: none;
}


</style>